package com.example.designpattern.delegate;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author long
 * @date 2024/11/16 22:15
 */
//@Primary
//@Service
public class CheckServiceDelegate implements ICheckService{

    @Resource
    private ICheckService freeCheckServiceImpl;

    @Resource
    private ICheckService sendCheckServiceImpl;

    @Override
    public void doCheck(Integer type) {
        getCheckService(type).doCheck(type);
    }

    private ICheckService getCheckService(Integer type){
        return CheckTypeEnum.isFreeCheck(type) ? freeCheckServiceImpl : sendCheckServiceImpl;
    }

}
